package ControlComponents;


/**
 * 
 *  This class represents a 4 bit status register
 *
 */
public class StatusRegister {

	/**
	 * 
	 */
	private int status[] = new int[4];
	
	/**
	 * Initialize the status register
	 */
	public StatusRegister( ){
		for( int position = 0; position < 4; position++ )
			status[ position ] = 0;
	}
	
	/**
	 * Get the status register
	 * @return the status register
	 */
	public int[] get(){
		return status;
	}
	
	/**
	 * Set the zero flag
	 */
	public void setZero( ){ status[0] = 1; }
	
	/**
	 * Set the carry flag
	 */
	public void setCarry( ){ status[1] = 1; }
	
	/**
	 * Set the negative flag
	 */
	public void setNegative( ){ status[2] = 1; }
	
	/**
	 * Set the overflow flag
	 */
	public void setOverflow( ){ status[3] = 1; }
	
	/**
	 * Clear the zero flag
	 */
	public void clearZero( ){ status[0] = 0; }
	
	/**
	 * Clear the carry flag
	 */
	public void clearCarry( ){ status[1] = 0; }
	
	/**
	 * Clear the negative flag
	 */
	public void clearNegative( ){ status[2] = 0; }
	
	/**
	 * Clear the overflow flag
	 */
	public void clearOverflow( ){ status[3] = 0; }
	
	/**
	 * Gets the zero flag
	 */
	public int getZero( ){ return status[0]; }
	
	/**
	 * Gets the carry flag
	 */
	public int getCarry( ){ return status[1]; }
	
	/**
	 * Gets the negative flag
	 */
	public int getNegative( ){ return status[2]; }
	
	/**
	 * Gets the overflow flag
	 */
	public int getOverflow( ){ return status[3]; }


	/**
	 * Override status register
	 * @param data is copied into status register
	 */
	public void set(int[] data) { 
		for( int i = 0; i < data.length; i++ )
			status[i] = data[i];
		
	}
}
